import com.sun.corba.se.impl.legacy.connection.SocketFactoryContactInfoListImpl;

/**
 * Keafmd
 *
 * @ClassName: demo2
 * @Description: demo2
 * @author: lijl
 * @date: 2022/11/30 14:14
 * @Blog: https://keafmd.blog.csdn.net/
 */
interface Solid{
    double area();
    double volume();
}
class Cube implements Solid{
    private double length;
    private double width;
    private double height;
    Cube(double length, double width, double height) {
        this.length = length;
        this.width = width;
        this.height = height;
    }
    public double area() {
        return 2 * (length * width + length * height + width * height);
    }
    public double volume() {
        return length * width * height;
    }
}
class Sphere implements Solid{
    private double r;
    Sphere(double r) {
        this.r = r;
    }
    public double area() {
        return 4 * Math.PI * r * r;
    }
    public double volume() {
        return (4 / 3.0) * Math.PI * r * r * r;
    }
}
public class demo2 {
    public static void main(String[] args) {
        Cube cube = new Cube(3,4,5);
        System.out.println("立方体的表面积为："+cube.area());
        System.out.println("立方体的体积为：  "+cube.volume());
        Sphere sphere = new Sphere(6);
        System.out.printf("球的表面积为:%.2f\n", sphere.area());
        System.out.printf("球的体积为： %.2f\n", sphere.volume());
    }
}
